package com.mastermind;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.mastermind.games.BasicMastermind;
import com.mastermind.games.Mastermind;

public class MastermindGamePanel extends JPanel {
	
	Mastermind game;
	
	public MastermindGamePanel() {
		setPreferredSize(CONFIG.WINDOW_SIZE);
		setBackground(Color.LIGHT_GRAY);
		
		game = new BasicMastermind();
		game.setFont(getFont());
	}
	
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		
		Graphics2D g2 = (Graphics2D)g;
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		
		draw(g2);
		repaint();
	}

	private void draw(Graphics2D g) {
		game.drawBoard(g);
	}

	public void click(MouseEvent e) {
		game.click(e);
	}

	public void mouse(MouseEvent e) {
		game.mouse(e);		
	}

	public void setContainer(JFrame frame) {
		game.setContainer(frame);		
	}
}
